package study.web.service.cxf.soap11.server;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

import study.web.service.cxf.soap11.service.IWeatherService;
import study.web.service.cxf.soap11.service.impl.WeatherServiceImpl;


/**  
* @Name: WeatherServer
* @Description: 天气信息查询服务发布（cxf发布jaxws服务类）
* @Author: 李超
* @Create Date: 2017-01-07
*/
public class WeatherServer {
	
	public static void main(String[] args) {
		//1、创建服务工厂bean
		JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean() ;
		//2、指定服务接口
		factoryBean.setServiceClass(IWeatherService.class) ;
		//3、指定服务实现对象
		factoryBean.setServiceBean(new WeatherServiceImpl()) ;
		//4、指定webservice地址
		factoryBean.setAddress("http://127.0.0.1:12345/weather") ;
		//添加输入日志拦截器：在服务方法执行前执行
		factoryBean.getInInterceptors().add(new LoggingInInterceptor()) ;
		//添加输出日志拦截器：在服务方法执行之后执行
		factoryBean.getOutInterceptors().add(new LoggingOutInterceptor()) ;
		//5、发布webservice服务
		factoryBean.create() ;
	}

}
